home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.src.lzh / libc / emalloc.c < prev    next >
C/C++ Source or Header  |  1989-07-05  |  403b  |  26 lines

  1. /*
  2.  * emalloc - malloc with Error() called when out of space
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <sys/types.h>
  7. #include "libc.h"
  8.  
  9. extern void Error();
  10.  
  11. char *
  12. emalloc(amount)
  13. unsigned amount;
  14. {
  15.     register char *it;
  16.     char camount[25];        /* Enough to sprintf an unsigned. */
  17.  
  18.     it = malloc(amount);
  19.     if (it == NULL) {
  20.         sprintf(camount, "%u", amount);
  21.         Error("malloc(%s) failed", camount);
  22.     }    
  23.  
  24.     return(it);
  25. }
  26.